<?php
require_once(dirname(__FILE__).'/simpletest/autorun.php');

require_once(dirname(__FILE__).'/tools.php');

require_once(ROOT_PATH.'/app/classes/model.php');
require_once(ROOT_PATH.'/app/models/path.php');
require_once(ROOT_PATH.'/app/models/directory.php');
require_once(ROOT_PATH.'/app/models/file.php');
require_once(ROOT_PATH.'/app/models/image.php');
require_once(ROOT_PATH.'/app/models/imagejpg.php');
require_once(ROOT_PATH.'/app/models/pathfactory.php');
require_once(ROOT_PATH.'/app/models/imagefactory.php');

class TestOfPath extends UnitTestCase {
	function setUp() {		
        	Tools::copyDirRecursive(ROOT_PATH.'/unit_testing/tests/backup/testFolder', ROOT_PATH_TESTDIR);
    	}
    
	function tearDown() {
		Tools::removeDirRecursive(ROOT_PATH_TESTDIR);
	}
	
	function testPathInstance() {
		$path = new Ab_Path(ROOT_PATH_TESTDIR);
		$this->assertTrue(is_a($path, 'Ab_Path'),'Routine Test:  Check instance type');
	}
	
	function testRelativePath(){
		$path = new Ab_Path(ROOT_PATH_TESTDIR.'/a.txt');
		$path->setRootDir(ROOT_PATH);
		
		$relative_path=$path->getRelativePath();
		$expected_path='/unit_testing/tests/temp/testFolder/a.txt';
		
		$this->assertEqual($result=$relative_path,$expected=$expected_path,'Relative Path');
		
	}
	
	function testPathDirectoryType(){
		$path = new Ab_Path(ROOT_PATH_TESTDIR);
		$directory=$path->getPathType();
		
		$this->assertTrue(is_a($directory, 'Ab_Directory'),'Test:  Check instance type: directory');
	}
	
	function testPathFileType(){
		$path = new Ab_Path(ROOT_PATH_TESTDIR.'/a.txt');
		$file=$path->getPathType();
		
		$this->assertTrue(is_a($file, 'Ab_File'),'Test:  Check instance type: file');
	}
	
	function testPathImageType(){
		$path = new Ab_Path(ROOT_PATH_TESTDIR.'/header-shooting.jpg');
		$image=$path->getPathType();
		
		$this->assertTrue(is_a($image, 'Ab_Image'),'Test:  Check instance type: image');
	}
	

}
?>
